import request from "../../utils/request.js";
//自动化管理
//主机
//主机条件查询
export const getHostSearch_Api = (query) => {
  return request({
    method: "get", //请求方式
    url: "/automated/Intelligent/MonitorHost/hosts", //请求地址
    params: query,
  });
};
//主机列表
export const getHostList_Api = () => {
  return request({
    method: "get", //请求方式
    url: "/automated/Intelligent/ScriptExecution/list", //请求地址
  });
};
// 根据主机id集合删除主机
export const getHostDelete_Api = (hostids) => {
  return request({
    method: "delete", //请求方式
    url: "/automated/Intelligent/MonitorHost/hostDelete/" + hostids, //请求地址
  });
};
//主机组列表
export const getHostListGroup_Api = () => {
  return request({
    method: "get", //请求方式
    url: "/automated/Intelligent/MonitorHost/groups", //请求地址
  });
};
//脚本列表
export const getScriptList_Api = () => {
  return request({
    method: "get", //请求方式
    url: "/automated/Intelligent/ScriptExecution/scriptsList", //请求地址
  });
};
//脚本执行
export const ScriptExecution_Api = (data) =>
  request.post("/automated/Intelligent/ScriptExecution/execution", data);

//自动选择主机组模板
export const getChoiceHostModel_Api = (data) => {
  return request({
    method: "post", //请求方式
    url: "/config/add/auto/host", //请求地址
    data,
  });
};
//编辑主机
export const getUpdateHost_Api = (data) => {
  return request({
    method: "put", //请求方式
    url: "/config/update/host", //请求地址
    data,
  });
};
//主机最新数据展示
export const getNewData_Api = (id) => {
  return request({
    method: "get", //请求方式
    url: "/automated/Intelligent/MonitorHost/newData/" + id, //请求地址
  });
};

//修改主机状态
export const updateHostStatus_Api = (data) => {
  return request({
    method: "put", //请求方式
    url:
      "/automated/Intelligent/MonitorHost/change?hostid=" +
      data.hostid +
      "&status=" +
      data.status, //请求地址
  });
};

//监控项
/**
 * 监控项查询
 * @param {*} query
 * @returns
 */
export const getMonitor_Api = (data) => request.post("/item/get", data);
/**
 * 监控项添加
 * @param {*} data
 * @returns
 */
export const addMonitor_Api = (data) => request.post("/item/add", data);
/**
 * 监控项编辑
 * @param {*} data
 * @returns
 */
export const updateMonitor_Api = (data) => request.put("/item/update", data);
/**
 * 监控项删除
 * @param {*} ids //监控项id
 * @returns
 */
export const delMonitor_Api = (ids) => request.delete("/item/delete/" + ids);
/**
 * 查监控项键值类型数据
 * @param {*}
 * @returns
 */
export const getMonitorKey_List_Api = () => request.get("/zy/type/list");
/**
 * 根据键值类型id查询键值
 * @param {*}
 * @returns
 */
export const getKey_byId_Api = (query) =>
  request.get("/zy/key/list", {
    params: query,
  });

//触发器
/**
 * 触发器查询
 * @param {*} query
 * @returns
 */
export const getTrigger_Api = (data) => request.post("/trigger/get", data);
/**
 * 触发器添加
 * @param {*} data
 * @returns
 */
export const addTrigger_Api = (data) => request.post("/trigger/add", data);
/**
 * 触发器编辑
 * @param {*} data
 * @returns
 */
export const updateTrigger_Api = (data) => request.put("/trigger/update", data);
/**
 * 触发器删除
 * @param {*} ids
 * @returns
 */
export const delTrigger_Api = (ids) => request.delete("/trigger/delete/" + ids);

/**
 * 获取应用程序列表
 * @param {*} query :name , hostid
 * @returns
 */
export const getAppList_Api = (query) =>
  request.get("/automated/applicationprogram/list", {
    params: query,
  });

/**
 * 删除应用程序
 * @param {*} id
 * @returns
 */
export const delApp_Api = (id) =>
  request.delete("/automated/applicationprogram/" + id);
/**
 * 根据id查询应用程序
 * @param {*} id
 * @returns
 */
export const getApp_Api = (id) =>
  request.get("/automated/applicationprogram/" + id);
/**
 * 修改应用程序
 * @param {*} data
 * @returns
 */
export const updateApp_Api = (data) =>
  request.put("/automated/patchlibrary", data);
/**
 * 应用程序分发
 * @param {*} data
 * @returns
 */
export const dispenseApp_Api = (data) =>
  request.post("/automated/applicationprogram/dispense", data);

//补丁分析和分发
/**
 * 补丁分析和分发查询
 * @param {*} hostid
 * @returns
 */

export const getPatchList_Api = (query) => {
  return request({
    method: "get", //请求方式
    url: "/automated/patchlibrary/list", //请求地址
    params: query,
  });
};
/**
 * 删除补丁
 * @param {*} id
 * @returns
 */
export const delPatch_Api = (id) =>
  request.delete("/automated/patchlibrary/" + id);

/**
 * 加载配置文件
 * @param {*} data
 * @returns
 */
export const addloadfile_Api = (data) =>
  request.post("/automated/configcorrect/loadConfig", data);

/**
 * 更新配置
 * @param {*} data
 * @returns
 */
export const editloadfile_Api = (data) =>
  request.post("/automated/configcorrect/correctConfigSubmit", data);

/**
 * 补丁分发
 * @param {*} data
 * @returns
 */
export const dispensePatch_Api = (data) =>
  request.post("/automated/patchlibrary/dispense", data);

/**
 * 查询信息
 * @param {*} id
 * @returns
 */
export const getinfoPatch_Api = (id) =>
  request.get("/automated/patchlibrary/" + id);

/**
 * 健康检查查询
 */
export const gethealthexamination_Api = () => {
  return request({
    method: "get", //请求方式
    url: "intelligent/healthCheck/list", //请求地址
  });
};
